﻿using System;
using ProdControls.Utility;
using ProdControls.Verification;
using ProdLogging;
using ProdUI.Hook.NativePatterns;

namespace ProdControls
{
    /// <summary>
    ///   Sends TrackBar Messages
    /// </summary>
    internal sealed class ProdSliderNative
    {
        internal static void SetValueNative(IntPtr windowHandle, double value)
        {
            LogController.ReceiveLogMessage(new LogMessage("Using SendMessage"));
            NativeMethods.SendMessage(windowHandle, (int) TrackBarMessages.TBM_SETPOS, 1, (int) value);
            ValueVerifier<double, double>.Verify(value, GetValueNative(windowHandle));
        }

        internal static double GetValueNative(IntPtr windowHandle)
        {
            LogController.ReceiveLogMessage(new LogMessage("Using SendMessage"));
            return (double) NativeMethods.SendMessage(windowHandle, (int) TrackBarMessages.TBM_GETPOS, 0, 0);
        }

        internal static double GetMinimumNative(IntPtr windowHandle)
        {
            LogController.ReceiveLogMessage(new LogMessage("Using SendMessage"));
            return (double) NativeMethods.SendMessage(windowHandle, (int) TrackBarMessages.TBM_GETRANGEMIN, 0, 0);
        }

        internal static double GetMaximumNative(IntPtr windowHandle)
        {
            LogController.ReceiveLogMessage(new LogMessage("Using SendMessage"));
            return (double) NativeMethods.SendMessage(windowHandle, (int) TrackBarMessages.TBM_GETRANGEMAX, 0, 0);
        }

        internal static IntPtr GetLargeChangeNative(IntPtr windowHandle)
        {
            LogController.ReceiveLogMessage(new LogMessage("Using SendMessage"));
            return NativeMethods.SendMessage(windowHandle, (int) TrackBarMessages.TBM_GETPAGESIZE, 0, 0);
        }

        internal static IntPtr GetSmallChangeNative(IntPtr windowHandle)
        {
            LogController.ReceiveLogMessage(new LogMessage("Using SendMessage"));
            return NativeMethods.SendMessage(windowHandle, (int) TrackBarMessages.TBM_GETLINESIZE, 0, 0);
        }
    }
}